package cz.muni.fi.pa036is.dtoconverters;

import cz.muni.fi.pa036is.dto.RoundFormTO;
import cz.muni.fi.pa036is.dto.RoundGridTO;
import cz.muni.fi.pa036is.entity.Round;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Shebik
 */
public class RoundConverter {

    public static Round convertToRound(final RoundFormTO roundFormTO) {
        final Round round = new Round();
        round.setId(roundFormTO.getId());
        round.setPointCount1(roundFormTO.getPointCount1());
        round.setPointCount2(roundFormTO.getPointCount2());
        round.setSequenceNumber(roundFormTO.getSequenceNumber());
        round.setMatchId(roundFormTO.getMatch().getId());
        return round;
    }

    public static RoundFormTO convertToRoundFormTO(final Round round) {
        final RoundFormTO roundFormTO = new RoundFormTO();
        roundFormTO.setId(round.getId());
        roundFormTO.setPointCount1(round.getPointCount1());
        roundFormTO.setPointCount2(round.getPointCount2());
        roundFormTO.setSequenceNumber(round.getSequenceNumber());
        return roundFormTO;
    }

    public static RoundGridTO convertToRoundGridTO(final Round round) {
        final RoundGridTO roundGridTO = new RoundGridTO();
        roundGridTO.setId(round.getId());
        roundGridTO.setPointCount1(round.getPointCount1());
        roundGridTO.setPointCount2(round.getPointCount2());
        roundGridTO.setSequenceNumber(round.getSequenceNumber());
        return roundGridTO;
    }

    public static List<RoundGridTO> convertToRoundGridTOList(
            final List<Round> roundList) {
        final List<RoundGridTO> roundGridTOList = new ArrayList<RoundGridTO>();

        for (final Round round : roundList) {
            roundGridTOList.add(convertToRoundGridTO(round));
        }
        return roundGridTOList;
    }

}
